<%@page import="org.springframework.context.annotation.Bean"%>
<%@page import="com.fooddiary.web.form.EatingTypeForm"%>
<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@include file="../public/header.jsp" %>

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/jquery-ui-1.8.17.custom.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/lib/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/lib/jquery-ui-i18n.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/lib/jquery.ui.timepicker.js"></script>

<img src="<%=request.getContextPath()+"/resources/images/editeating_logo.jpg"%>" class="logo">

<div class="form-wrapper editeating-form-wrapper"> 
	<div class="form-header">
		<div class="form-title">
			<fmt:message key="label.edit.eating.title"></fmt:message>
		</div> 
	</div>
	<div class="form-body">
		<form:form id="editEatingFormId" method="post" action="/private/eating/saveEating.action" modelAttribute="eatingForm">
			<form:hidden path="id"/>
			<form:hidden path="enabled"/>
			<form:hidden path="weightId"/>
			<!--<form:hidden path="eatingTypeId"/>-->
			<div class="form-button-wrapper2 trenning-wrapper">
				<label for="overweightFieldId" class="label-check-select">
    				<fmt:message key="label.eating.type"></fmt:message>: 
    			</label>
				<form:select path="eatingTypeId" id="typeFieldId" cssClass="eating-type-select">
				<form:options  items="${eatingTypes}" itemValue="id" itemLabel="displayName"/>
				</form:select>
			</div>
			<label id="timeFieldLabelId" for="timrFieldId" class="form-label editeating-form-field-label">
				<fmt:message key="label.time"></fmt:message>:
			</label> 
			<form:input path="time" id="timeFieldId" cssClass="form-field editeating-form-field"/>
    		<label id="foodFieldLabelId" for="foodFieldId" class="form-label editeating-form-field-label">
    			<fmt:message key="label.food"></fmt:message>:
    		</label>
    		<form:textarea id="foodFieldId" path="food" cssClass="form-field form-textarea"/> 
			<div class="form-button-wrapper2 trenning-wrapper">
    			<form:checkbox  path="overweight" id="trenningFieldId" cssClass="checkbox"/>
    			<label for="overweightFieldId" class="label-check-select">
    				<fmt:message key="label.overweight"></fmt:message> 
    			</label>
    		</div>
    		<div class="registration-form-button-wrapper">
    			<a href="<%=request.getContextPath()+"/private/weight/initEditWeight.action?id="%>${eatingForm.weightId}" class="form-button form-button-back-to-login">
    				<fmt:message key="button.back"></fmt:message>
    			</a>
    			<input type="button" id="clearButtonId" value=<fmt:message key="button.clear"></fmt:message> class="form-button form-button-registration-clear" /> 
    			<input type="button" id="saveButtonId" value=<fmt:message key="button.save"></fmt:message> class="form-button form-button-register"/>
    		</div>
         </form:form>
	</div>
	<div class="form-footer">
	</div>
</div>

<div class="form-wrapper registration-form-error-wrapper">
	<div class="form-header">
		<div class="form-title form-error-title">
			<fmt:message key="label.error"></fmt:message>
		</div>
	</div>
	<ul id="errorsListId" class="form-error-text">
		<c:forEach var="err" items="${eatingForm.errors}">
			<li>${err}</li>
		</c:forEach>
	</ul>		
	<div class="form-footer"></div>
</div>

<c:if test="${not empty eatingForm.errors}">
	<script type="text/javascript">
		$('.registration-form-error-wrapper').css('display', 'inline-block');
	</script>
</c:if>

<script type="text/javascript">
	var messages = new Array();
	messages['message.error.field'] = '<fmt:message key="message.error.field"/>';
	messages['message.error.empty'] = '<fmt:message key="message.error.empty"/>';
	messages['message.error.field.length'] = '<fmt:message key="message.error.field.length"/>';
	messages['message.error.length.greater'] = '<fmt:message key="message.error.length.greater"/>';
	messages['message.error.passwords.not.equal'] = '<fmt:message key="message.error.passwords.not.equal"/>';
	messages['message.error.field.contain.incorrect.symbols'] = '<fmt:message key="message.error.field.contain.incorrect.symbols"/>';
	messages['message.error.field.invalid.format'] = '<fmt:message key="message.error.field.invalid.format"/>';
</script>

<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/app/eating.js"></script>
<%@include file="../public/footer.jsp" %>	